//
//  ChangePhoneTwoViewController.m
//  NewPro
//
//  Created by RYX on 2019/4/26.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "ChangePhoneOneViewController.h"
#import "ChangePhoneTwoViewController.h"
#import "SetStore.h"

@interface ChangePhoneOneViewController ()
@property (weak, nonatomic) IBOutlet UITextField *loginPassTf;

@end

@implementation ChangePhoneOneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColor.whiteColor;
    [self setNavBarWithTitle:@"验证手机号码"];
    _loginPassTf.clearButtonMode = UITextFieldViewModeWhileEditing;
    _loginPassTf.secureTextEntry = YES;
}

#pragma mark - 密文状态控制
- (IBAction)onEyeBtn:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    if (sender.selected) {
        
        _loginPassTf.secureTextEntry = NO;
    }else{
        
        _loginPassTf.secureTextEntry = YES;
    }
}

#pragma mark - 确定
- (IBAction)onSureBtn:(UIButton *)sender {
    
    if (_loginPassTf.text.length <= 0) {
        
        return [self showMBPError:@"请输入登录密码"];
    }
    
    sender.enabled = NO;
    
    MJWeakSelf
    SetStore *store = [[SetStore alloc] init];
    [store judgeLoginPassWithPassword:[_loginPassTf.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] Success:^{
        
        sender.enabled = YES;
        ChangePhoneTwoViewController *VC = [[ChangePhoneTwoViewController alloc] init];
        [weakSelf.navigationController pushViewController:VC animated:YES];
    } Failure:^(NSError *error) {
        
        sender.enabled = YES;
        [weakSelf showMBPError:[HttpTool handleError:error]];
    }];
    
}

@end
